package com.jingmai.video.live.shortvideo.data.controller;
import com.jingmai.video.live.shortvideo.data.model.LkLiveVideoDataServedUserPO;
import com.jingmai.video.live.shortvideo.data.service.LkLiveVideoDataServedUserService;
import com.common.utils.ResultUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.common.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import javax.validation.Valid;
import java.util.List;

/**
* <p>
* 维护用户表 前端控制器
* </p>
*
* @author lying
* @since 2024-03-22
*/
@Api(tags = "维护用户表")
@RestController
@RequestMapping("amz/lk-live-video-data-served-user-po")
public class LkLiveVideoDataServedUserController {

    @Autowired
    private LkLiveVideoDataServedUserService lkLiveVideoDataServedUserService;

    @ApiOperation(value = "维护用户表分页列表", response = LkLiveVideoDataServedUserPO.class)
    @ApiImplicitParams({
        @ApiImplicitParam(name = "pager", value = "页面", dataType = "Long"),
        @ApiImplicitParam(name = "pageSize", value = "页面数据量", dataType = "Long")})
    @PostMapping(value = "/page")
    public  Result< IPage <LkLiveVideoDataServedUserPO>> list(@Valid @RequestBody LkLiveVideoDataServedUserPO param,
                                            @RequestParam(value = "pager",required = false,defaultValue = "1") Long pager,
                                            @RequestParam(value = "pageSize",required = false,defaultValue = "10") Long pageSize) {
            IPage<LkLiveVideoDataServedUserPO> page = new Page<>(pager,pageSize);
        return ResultUtils.success(lkLiveVideoDataServedUserService.page(param,page));
    }

    @ApiOperation(value = "维护用户表根据id查询", response = LkLiveVideoDataServedUserPO.class)
    @GetMapping(value = "/getById/{id}")
    public  Result<LkLiveVideoDataServedUserPO> getById(@PathVariable Long id) {
        return ResultUtils.success(lkLiveVideoDataServedUserService.info(id));
    }

    @ApiOperation(value = "维护用户表新增")
    @PostMapping(value = "/add")
    public Result add(@Valid @RequestBody LkLiveVideoDataServedUserPO param) {
        lkLiveVideoDataServedUserService.add(param);
        return ResultUtils.success();
    }

    @ApiOperation(value = "维护用户表修改")
    @PostMapping(value = "/update")
    public Result update(@Valid @RequestBody LkLiveVideoDataServedUserPO param) {
        lkLiveVideoDataServedUserService.modify(param);
        return ResultUtils.success();
    }

    @ApiOperation(value = "维护用户表删除(多个条目)")
    @PostMapping(value = "/removes")
    public Result removes(@Valid @RequestBody List<Long> ids) {
        lkLiveVideoDataServedUserService.removes(ids);
        return ResultUtils.success();
    }

}
